package jghoman;

import com.twitter.finagle.ListeningServer;
import com.twitter.finagle.Thrift;
import com.twitter.finagle.example.thriftscala.Hello;
import com.twitter.util.Await;
import com.twitter.util.Closable;
import com.twitter.util.Closables;
import com.twitter.util.Future;
import com.twitter.util.TimeoutException;
import scala.runtime.BoxedUnit;

public class ThriftServer implements Hello<Future> {


    public static void main(String[] args) throws Exception {
        ListeningServer server = Thrift.server().serveIface("127.0.0.1:8080", new ThriftServer());

        Await.result(server);
    }

    @Override
    public Future<String> hi() {
        System.out.println("implement hi");
        return Future.value("hi");
    }



}

//public final class ThriftServer {
//
//  private ThriftServer() { }
//
//  public static class HelloImpl implements Hello<Future> {
//
//
//    public Future<String> hi() {
//      return Future.value("hi");
//    }
//
//    @Override
//    public Closable asClosable() {
//      return Closables.NOP;
//    }
//  }
//
//  /**
//   * Runs the example with given {@code args}.
//   *
//   * @param args the argument list
//   */
//  public static void main(String[] args) throws Exception {
//    //#thriftserverapi
//
//      ListeningServer server = Thrift.server().serveIface("localhost:8080", new ThriftServer());
//
//      Await.result(server);
//
////    Hello impl = new HelloImpl();
////    ListeningServer server = Thrift.server().serveIface("localhost:8080", impl);
////    Await.ready(server);
//    //#thriftserverapi
//  }
//}
